package com.md.value.enums;

import com.md.base.EnumBase;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author 刘骄阳
 * 2024-10-10 18:51
 */
@Getter
@AllArgsConstructor
public enum OperationEnum implements EnumBase {
  /**
   * 增
   */
  INSERT(0, "添加"),
  /**
   * 删
   */
  DELETE(1, "删除"),
  /**
   * 改
   */
  UPDATE(2, "修改"),
  /**
   * 查
   */
  SELECT(3, "查询"),
  /**
   * 导出
   */
  EXPORT(4, "导出"),
  /**
   * 导入
   */
  INPUT(5, "导入"),
  /**
   * 登录
   */
  LOGIN(6, "登录");

  private static final Map<Integer, OperationEnum> ENUM_MAP = Arrays.stream(OperationEnum.values())
    .collect(Collectors.toMap(EnumBase::getCode, e -> e));
  private final Integer code;
  private final String message;

  public static OperationEnum of(final Integer code) {
    return ENUM_MAP.get(code);
  }
}
